
public class Camera extends GameObject {
	private double horAngle, verAngle;
	private double vrpX, vrpY, vrpZ;
	private double dx,dy,dz;
	private int gridX,gridZ;
	private double vuvX, vuvY, vuvZ;
	private double speedX, speedY, speedZ; 
	private final double dh;
	private float tempHeight=0.0f;
	private double speedCorrect;
	
	public Camera( double x, double y, double z, double h, double v )
	{
		// Set the initial position and viewing direction of the player.
		super( x, y, z );
		horAngle = h;
		verAngle = v;
		speedX =0;
		speedY=0;
		speedZ=0;
		dh=2;
		speedCorrect=255.5;
		// Calculate a likely view reference point.
		calculateVRP();
		
		// Set the view up vector to be parallel to the y-axis of the world.
		vuvX = 0.0;
		vuvY = 1.0;
		vuvZ = 0.0;
	}

	
	
	public void calculateVRP()
	{
		float sinA =(float)Math.sin(Math.toRadians(getHorAngle()));
		float cosA =(float)Math.cos(Math.toRadians(getHorAngle()));
		locationX +=sinA*speedZ/speedCorrect+cosA*speedX/speedCorrect;
		locationZ +=cosA*speedZ/speedCorrect-sinA*speedX/speedCorrect;
		
		/**
		gridX = World.getGrid(locationX);
		gridZ=World.getGrid(locationZ);
		tempHeight=0;
		for(int dh=-1;dh<=+1;dh++)
		{
			for(int dw=-1;dw<=+1;dw++)
			{
				if(World.HEIGHT_MAP[gridX+dw][gridZ+dh]>tempHeight)tempHeight = World.HEIGHT_MAP[gridX+dw][gridZ+dh];
			}
		}
		speedY = tempHeight- locationY+dh;
		if(speedY>0)locationY += speedY/5.0;
		else locationY += speedY/50.0;
		*/
		dx = -Math.sin( Math.PI * horAngle / 180 ) * Math.cos( Math.PI * verAngle / 180 );
		dy = Math.sin( Math.PI * verAngle / 180 );
		dz = -Math.cos( Math.PI * horAngle / 180 ) * Math.cos( Math.PI * verAngle / 180 );
		
		vrpX = locationX + dx;
		vrpY = locationY + dy;
		vrpZ = locationZ + dz;
		
		speedX*=0.99;
		speedZ*=0.99;

	}

	public void setSpeedX(int inc)
	{
		speedX+=inc;
	}
	
	public void setSpeedY(int inc)
	{
		speedY+=inc;
	}
	
	public void setSpeedZ(int inc)
	{
		speedZ+=inc;
	}	
	
	public double getDx()
	{
		return dx;
	}
	
	public double getDy()
	{
		return dy;
	}
	
	public double getDz()
	{
		return dz;
	}
	
	public double getHorAngle() 
	{
		return horAngle;
	}

	public void setHorAngle(double horAngle)
	{
		this.horAngle = horAngle;
	}

	public double getVerAngle()
	{
		return verAngle;
	}

	public void setVerAngle(double verAngle) 
	{
		if(verAngle>-85&&verAngle<85)this.verAngle = verAngle;
	}

	public double getVrpX()
	{
		return vrpX;
	}

	public void setVrpX(double vrpX) 
	{
		this.vrpX = vrpX;
	}

	public double getVrpY() 
	{
		return vrpY;
	}

	public void setVrpY(double vrpY) 
	{
		this.vrpY = vrpY;
	}

	public double getVrpZ() 
	{
		return vrpZ;
	}

	public void setVrpZ(double vrpZ)
	{
		this.vrpZ = vrpZ;
	}

	public double getVuvX() 
	{
		return vuvX;
	}

	public void setVuvX(double vuvX) 
	{
		this.vuvX = vuvX;
	}

	public double getVuvY() 
	{
		return vuvY;
	}

	public void setVuvY(double vuvY) 
	{
		this.vuvY = vuvY;
	}

	public double getVuvZ() 
	{
		return vuvZ;
	}

	public void setVuvZ(double vuvZ) 
	{
		this.vuvZ = vuvZ;
	}
	
	public void moveCamera()
	{
		
	}
	
}
